
<template>
<div class="page-container page-container-detail-page" :style="{height:HEIGHT+'px'}">
  <!--面包屑导航-->
    <div class="breadcrumb">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item>会员中心</el-breadcrumb-item>
        <el-breadcrumb-item>会员积分管理</el-breadcrumb-item>
        <el-breadcrumb-item>基础设置</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="page-container-detail">
  <el-form   :rules="dataFormRules" :ref="dataform" :model="dataform"   class="dataForm labelFontSize">
    <p class="title">基础设置</p>
    <el-row class="search-input">
      <el-form-item label="积分抵现比例：" prop="integral" class="rate mb30" label-width="174px">
        <el-input v-model.number="dataform.integral" maxlength="5" oninput="value=value.replace(/[^\d]/g,'')" placeholder="请输入比例"  class="mr10" clearable></el-input>
        <span class="font18 color666">积分: </span>
        <el-input  prop="rmb"   v-model.number="dataform.rmb" maxlength="5" oninput="value=value.replace(/[^\d]/g,'')" placeholder="请输入金额" class="mr10" clearable></el-input>
        <span class="font18 color666">人民币</span>
      </el-form-item>
    <el-form-item label="每日获取积分上限：" class="mb30" label-width="175px">
      <el-input  class="longInput mr10" v-model.number="dataform.dailyCeiling" maxlength="5"  oninput="value=value.replace(/[^\d]/g,'') "  placeholder="请输入每日获取积分上限"  clearable></el-input>
      <span class="font18 color666">积分</span>
    </el-form-item>
    <el-form-item label="积分有效期：" class="mb20" label-width="174px">
      <el-input class="longInput mr10" v-model.number="dataform.maxGrowthValue" maxlength="5" oninput="value=value.replace(/[^\d]/g,'')" placeholder="请输入积分有效期" clearable></el-input>
      <span class="font18 color666">年</span>
    </el-form-item>
    <el-form-item>
      <span class="color999 text lh10">注:有效期至少为n年，即从获得积分开始至第n+1年年底(12月31日24点)，逾期自动作废；例如：有效期设置为1年，积分的失效时间为获得后的次年年底</span>
    </el-form-item>
    </el-row>

    <el-form-item class="btns">
      <el-button type="primary" @click="onSubmit(dataform)" >保存</el-button>
    </el-form-item>
  </el-form>
  </div>
  </div>
</template>

<script>
  import KtButton from "@/views/Core/KtButton";
  export default {
    components: {
      KtButton,
    },
    data() {

      return {
        HEIGHT:window.innerHeight,
        maxGrowthValue: null,
        dailyCeiling: null,
        rmb: null,
        integral: null,
        deptType:localStorage.getItem("deptType"),//当前登录用户所属组织类型
        dataform: {
          maxGrowthValue: null,
          dailyCeiling: null,
          rmb: null,
          integral: null
        },
        dataFormRules: {
          maxGrowthValue: [
            { required: true, message: '积分有效期不能为空'},
            { type: 'number', message: '必须为数字', trigger: "blur"}
          ],
          dailyCeiling: [
            { required: true, message: '每日获取积分上限不能为空'},
            { type: 'number', message: '必须为数字', trigger: "blur"}
          ],
          rmb: [
            { required: true, message: '金额不能为空'},
            { type: 'number', message: '必须为数字', trigger: "blur"}
          ],
          integral: [
            { required: true, message: '积分抵现比例不能为空'},
            { type: 'number', message: '必须为数字', trigger: "blur"}
          ]
        },
      }
    },
    methods: {
      onSubmit() {
        let _this = this;
        let param = {};
        param.storeMember=2;
        param.integral = _this.dataform.integral;
        param.dailyCeiling = _this.dataform.dailyCeiling;
        param.rmb = _this.dataform.rmb;
        param.maxGrowthValue = _this.dataform.maxGrowthValue;
        if(null ==_this.dataform.integral || _this.dataform.integral  =='' ){
          this.$message({message: '积分不能为空',type: 'error'});return;
        }if( null == _this.dataform.rmb ||  _this.dataform.rmb == ''){
          this.$message({message: '金额不能为空',type: 'error'});return;
        }else {
          this.utils.request.saveRulesInfo(param,function (res) {
            if(res.code == '0000'){
              _this.$message({ message: "操作成功", type: "success" });
              _this.getMemberBaseInfo()
            }else {
              _this.$message({
                message: "操作失败, "+res.msg ,
                type: "error"
              });
            }
          });
        }
      },

      getMemberBaseInfo() {
          let this_ = this;
          this_.utils.request.getMemberBaseInfo(this_.dataform, function(res) {
            if(res.code == '0000'){
              this_.dataform.integral = res.data.integral
              this_.dataform.rmb = res.data.rmb
              this_.dataform.dailyCeiling = res.data.dailyCeiling
              this_.dataform.maxGrowthValue = res.data.maxGrowthValue
            }
          })}

    },
    mounted() {
      this.getMemberBaseInfo();
    }
  }
</script>

<style lang="scss" scoped>
.title{
  font-size: 20px;
  color: #333333;
  margin-bottom: 35px;
} 
.rate{
  /deep/ .el-input{
    width: 112px !important;
  }
}
/deep/ .longInput{
  width: 285px !important;
}
.text{
  display: inline-block;
  width: 430px;
  font-size: 12px;
  margin-left: 68px;
  margin-bottom: 80px;
}
.mr10{
  margin-right: 10px;
}
.btns{
  padding-left: 174px;
}
.lh10{
  line-height: 20px;
}
</style>



